package com.fjec.im.config;

import com.fjec.common.rabbitmq.BaseCallback;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AmqpConfig {

    @Bean("compensateAmqpTemplate")
    public RabbitTemplate sysMessageAmqpTemplate(ConnectionFactory connectionFactory) {
        RabbitTemplate template = new RabbitTemplate(connectionFactory);
        BaseCallback baseCallback = new BaseCallback("MQ_SYS_MSG_COMPENSATE");
        //成功回调
        template.setConfirmCallback(baseCallback);
        //失败回调
        template.setReturnCallback(baseCallback);
        return template;
    }

}
